using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsUserControl.Dialogs
{
    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public delegate void OKButtonClicked(object sender, EventArgs e);

    /// <summary>
    /// 
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    public delegate void CancelButtonClicked(object sender, EventArgs e);

    /// <summary>
    /// 
    /// </summary>
    public partial class EmptyDialogContainer : Form
    {
        /// <summary></summary>
        public event OKButtonClicked OnOkButtonClicked;

        /// <summary></summary>
        public event CancelButtonClicked OnCancelButtonClicked;

        /// <summary>
        /// 
        /// </summary>
        public EmptyDialogContainer()
        {
            InitializeComponent();
        }

        private void EmptyDialogContainer_Load(object sender, EventArgs e)
        {

        }

        /// <summary>
        /// 
        /// </summary>
        public UserControl HostedControl
        {
			get
			{
				if (this.Controls.Count > 0)
					return this.Controls[0] as UserControl;
				else
					return null;
			}
            set
            {
                this.panel1.Controls.Clear();
                this.panel1.Controls.Add(value);
                value.Dock = DockStyle.Fill;
                this.Text = value.Name;
            }
        }

        private void btn_Cancel_Click(object sender, EventArgs e)
        {
            if(this.OnCancelButtonClicked !=null)
                this.OnCancelButtonClicked(this,new EventArgs());

            this.Close();
        }

        private void btn_OK_Click(object sender, EventArgs e)
        {
            if(this.OnOkButtonClicked !=null)
                this.OnOkButtonClicked(this,new EventArgs());

            this.Close();
        }
    }
}